package xufei.order.controller;

import com.xufei.common.domain.order.Order;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xufei.order.service.OrderService;
import java.math.BigDecimal;
import java.util.List;

@RestController
@RequestMapping("order")
public class OrderController {

    private final OrderService orderService;

    public OrderController(OrderService orderService) {
        this.orderService = orderService;
    }

    @RequestMapping("createOrder")
    public String createOrder(){
        Order order = new Order();
        order.setSno("2022227001");
        order.setProductId(100);
        order.setPrice(new BigDecimal(100.5));
        orderService.createOrder(order);
        return "success";
    }

    @RequestMapping("list")
    public List<Order> list(Order order){
        List<Order> orderList = orderService.selectOrderList(order);
        return orderList;
    }

}
